package nac.tanke;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;

public abstract class Entity {

  private Rectangle bounds = new Rectangle(0, 0, 0, 0);
  private Point vector = new Point(0, 0);
  private String id;
  private Stage stage;

  public Entity(Stage stage, String id, int x, int y, int width, int height) {
    this.stage = stage;
    this.id = id;
    this.bounds.setBounds(x, y, width, height);
  }

  public String getId() {
    return id;
  }

  public void move(long delta) {
    System.out.println("DELTA:" + delta);
    bounds.x += (delta * vector.x) / 1000;
    bounds.y += (delta * vector.y) / 1000;
    vector.x = 0;
    vector.y = 0;
  }

  public Point getVector() {
    return vector;
  }

  public Rectangle getBounds() {
    return bounds;
  }

  public void draw(Graphics g) {
    g.setColor(Color.GREEN);
    g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
  }

  public abstract void doLogic();
  
  public boolean collidesWith(Entity other) {
    return bounds.intersects(other.getBounds());
  }

  public abstract void collidedWith(Entity other);
}